#include "nobuttonnotice.h"
#include "ui_nobuttonnotice.h"

NoButtonNotice::NoButtonNotice(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::NoButtonNotice)
{
    ui->setupUi(this);

    /* 隐藏title */
    this->setWindowFlags(Qt::FramelessWindowHint);

}

NoButtonNotice::~NoButtonNotice()
{
    delete ui;
}

/* 改变提示窗口文字 */
void NoButtonNotice::changeText(QString text){
    ui->infomation->setText(text);
}

/* 改变提示窗口图标 */
void NoButtonNotice::changeIcon(QString iconUrl){
    QString stylesheet = "QLabel { background-image: " + iconUrl + "};";
    ui->label->setStyleSheet(stylesheet);
}

/* 窗口阴影 */
void NoButtonNotice::initSetShadow(QDialog*dialog)
{
    dialog->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | dialog->windowFlags());
    dialog->setAttribute(Qt::WA_TranslucentBackground, true);

    QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(dialog);
    shadow->setOffset(0, 0);                                                                            //设置阴影距离
    shadow->setColor(Qt::gray);                                                                //设置阴影颜色
    shadow->setBlurRadius(20);                                                                          //设置阴影圆角
    QWidget*widget = new QWidget(dialog);
    widget->setObjectName("widgetShadow");
    widget->setGraphicsEffect(shadow);  //设置阴影
    widget->setStyleSheet("#widgetShadow{background:#fff;border-radius:0px;}");//设置一下样式表，否则子窗口也会跟着透明

    QSize s= dialog->size();
    widget->resize(s);
    dialog->resize(s.width()+20,s.height()+20);
    widget->move(10,10);

    QHBoxLayout *shadowWidgetComponentsLayout = new QHBoxLayout();
    shadowWidgetComponentsLayout->addWidget(ui->label);
    shadowWidgetComponentsLayout->addWidget(ui->infomation);
    widget->setLayout(shadowWidgetComponentsLayout);

}
